<template>
  <div class="container">
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item :to="{ path: '/goodsCharge' }"
        >商品管理</el-breadcrumb-item
      >
      <el-breadcrumb-item>发布商品</el-breadcrumb-item>
    </el-breadcrumb>
    <el-card>
      <el-form :model="addGoodsForm" label-position="left" label-width="100px">
        <el-form-item label="商品标题" class="Goodsitem">
          <el-input v-model="addGoodsForm.goodStitle"></el-input>
        </el-form-item>
        <el-form-item label="简要描述" class="Goodsitem">
          <el-input v-model="addGoodsForm.jsdesc"></el-input>
        </el-form-item>
        <el-form-item label="上传图片" class="Goodsitem">
          <el-upload
            action="#"
            list-type="picture-card"
            :auto-upload="false"
            v-model="addGoodsForm.tupian"
          >
            <i slot="default" class="el-icon-plus"></i>
            <div slot="file" slot-scope="{ file }">
              <img
                class="el-upload-list__item-thumbnail"
                :src="file.url"
                alt=""
              />
              <span class="el-upload-list__item-actions">
                <span
                  class="el-upload-list__item-preview"
                  @click="handlePictureCardPreview(file)"
                >
                  <i class="el-icon-zoom-in"></i>
                </span>
                <span
                  v-if="!disabled"
                  class="el-upload-list__item-delete"
                  @click="handleDownload(file)"
                >
                  <i class="el-icon-download"></i>
                </span>
                <span
                  v-if="!disabled"
                  class="el-upload-list__item-delete"
                  @click="handleRemove(file)"
                >
                  <i class="el-icon-delete"></i>
                </span>
              </span>
            </div>
            <div slot="tip" class="el-upload__tip">
              只能上传jpg文件,最多五张
            </div>
          </el-upload>
          <el-dialog :visible.sync="dialogVisible">
            <img width="100%" :src="dialogImageUrl" alt="" />
          </el-dialog>
        </el-form-item>
        <el-form-item label="商品分类">
          <el-select v-model="addGoodsForm.category">
            <el-option label="服装" value="1"></el-option>
            <el-option label="数码" value="2"></el-option>
            <el-option label="食品" value="3"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="规格明细">
          <div class="guigeDiv"></div>
        </el-form-item>
        <el-form-item label="详细描述">
          <vue-editor v-model="addGoodsForm.xiangxidesc"></vue-editor>
        </el-form-item>
        <el-form-item label="是否允许评论">
          <el-switch
            v-model="addGoodsForm.isCommit"
            active-color="#13ce66"
            inactive-color="#ff4949"
          >
          </el-switch>
        </el-form-item>
        <el-form-item>
          <el-button type="success">发布</el-button>
          <el-button>取消</el-button>
        </el-form-item>
      </el-form>
    </el-card>
    <div style="height:30px"></div>
  </div>
</template>

<script>
import { VueEditor } from "vue2-editor";
{
  VueEditor;
}
export default {
  components: {
    VueEditor
  },
  data() {
    return {
      addGoodsForm: {},
      dialogImageUrl: "",
      dialogVisible: false,
      disabled: false
    };
  },
  methods: {
    handleRemove(file) {
      console.log(file);
    },
    handlePictureCardPreview(file) {
      this.dialogImageUrl = file.url;
      this.dialogVisible = true;
    },
    handleDownload(file) {
      console.log(file);
    }
  }
};
</script>

<style lang="scss" scoped>
.guigeDiv {
  width: 800px;
  height: 250px;
  border: 1px solid #dcdfe6;
}
.Goodsitem {
  width: 800px;
}
.el-upload__tip {
  font-size: 12px;
  color: #606266;
  margin-top: 0;
}
.el-textarea {
  width: 800px;
}
</style>
